
let string ='Aa-Bb-Cc-Dd'
let arr = string.split('-')
let string1 = arr[0]
let string2 = arr[1]+'-'+arr[2]+'-'+arr[3]
let newString = string1+','+string2
console.log(newString)

let Astring ='Aa-Bb-Cc-Dd'
let one = Astring.substr(0,2)
let two = Astring.substr(3)
let TheNew = one+','+two
console.log(TheNew)

let vstring ='Aa-Bb-Cc-Dd-g-h-j-f-g'
let hhh = vstring.split('-',1)
let gaga = vstring.split('-')
gaga.shift()
let aga=gaga.join('-')
let newS = String(hhh)+','+aga
let ca=newS.slice(0,vstring.length-1)
console.log(ca)

let gString = 'Aa-Bb-Cc-Dd-g-h-j-f-g-'
let weizhi = gString.indexOf('-')
let left = gString.substr(0,weizhi)
let right = gString.substr(weizhi+1)
let newG= left+','+right
console.log(newG)
let a=null;
if(gString.lastIndexOf('-')+1 == gString.length){ //判断最后一个是否为- 如果是-则切除 不是 不变
     a=newG.slice(0,gString.length-1)
}else{
    a=newG
}
console.log(a,'a')

// 时间 返回对象 y M d h m s
function timeHandle(time){
    var _time=time,
        dates,
        obj = {}
    dates = new Date(_time)
    obj.y = dates.getFullYear()
    obj.M = dates.getMonth() + 1
    obj.d = dates.getDate()
    obj.h = dates.getHours()
    obj.m = dates.getMinutes()
    obj.s = dates.getSeconds()
    obj.absS = parseInt(_time/1000%60)
    obj.absM = parseInt(_time/1000/60%60)
    obj.absH = parseInt(_time/1000/60/60%24)
    obj.absDD = parseInt(_time/1000/60/60/24)
    obj.absHH = parseInt((_time - obj.absDD*24*60*60*1000)/1000/60/60);
    return obj
}
Date.prototype.ft = function(format) {
    var o = {
      "M+": this.getMonth() + 1, // 月
      "d+": this.getDate(), // 日
      "h+": this.getHours(), // 时
      "m+": this.getMinutes(), // 分
      "s+": this.getSeconds(), // 秒
      "q+": Math.floor((this.getMonth() + 3) / 3), // 季节
      S: this.getMilliseconds() //毫秒数
    };
    if (/(y+)/.test(format)) {
      format = format.replace(
        RegExp.$1,
        (this.getFullYear() + "").substr(4 - RegExp.$1.length)
      );
    }
    for (var k in o) {
      if (new RegExp("(" + k + ")").test(format)) {
        format = format.replace(
          RegExp.$1,
          RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
        );
      }
    }
    return format;
  };

  function formatDate(secs, type) {
    var t = new Date(secs)
    var year = t.getFullYear()
    var month = t.getMonth() + 1
    if (month < 10) {
        month = '0' + month
    }
    var date = t.getDate()
    if (date < 10) {
        date = '0' + date
    }
    var hour = t.getHours()
    if (hour < 10) {
        hour = '0' + hour
    }
    var minute = t.getMinutes()
    if (minute < 10) {
        minute = '0' + minute
    }
    var second = t.getSeconds()
    if (second < 10) {
        second = '0' + second
    }
    if (type == 0) {
        return '' + year + '/' + month + '/' + date;
    } else {
        return year + '-' + month + '-' + date + " "+hour+":"+minute+":"+second;
    }
}
console.log(formatDate(1562914970000))
//获取某一年 某一一个月的一天为周几
let weeks = new Date(2019,06,17).getDay()
console.log('2019-07-17是周 : ',weeks)
//获取一个月有几天
let days = new Date(2019,07,0).getDate()
console.log(days,'2019年七月有几天?')

let nowDay = new Date()
console.log(nowDay.getTime(),'今天')
let oneDay = 24*60*60*1000
console.log(new Date(1563885764626+oneDay))